package com.cqie.ssm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqie.ssm.bean.User;
import com.cqie.ssm.bean.UserExample;
import com.cqie.ssm.dao.UserMapper;
import com.cqie.ssm.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Autowired(required = false)
	private UserMapper userMapper;
	
	public User selectUserByName(String userName) {
		UserExample userExample = new UserExample();
		userExample.or().andUserNameEqualTo(userName);
		List<User> users = userMapper.selectByExample(userExample);		
		if(users == null || users.size()==0) {
			return null;
		}
		return users.get(0);
	}

	@Override
	public List<User> selectByExample(UserExample userExample) {
		return userMapper.selectByExample(userExample);
	}

	@Override
	public void deleteUserById(Integer userid) {
		 userMapper.deleteByPrimaryKey(userid);		
	}

}
